<template>
  <div class="item" @click="onClick">
    <div class="name">
      {{ data.name }}
    </div>
    <div class="desc">
      {{ data.desc }}
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref, toRaw, onMounted, onUnmounted, PropType } from 'vue';
import { BundleInfo } from './data';

export default defineComponent({
  name: 'item',
  props: {
    data: {
      type: Object as PropType<BundleInfo>,
      default: () => {
        return {};
      },
    },
  },
  setup(props, { emit }) {

    return {
      onClick() {
        let url = props.data?.url;
        if (url) {
          if (!url.startsWith('http://') || url.startsWith('https://')) {
            url = 'http://' + url;
          }
          window.open(url);
        }
      },
    };
  },
});

</script>

<style scoped lang="scss">
.item {
  display: flex;
  flex-direction: column;
  height: 100px;
  padding-left: 40px;
  text-align: left;
  align-items: flex-start;
  justify-content: center;
  border-bottom: 1px solid #f2f2f2;

  &:hover {
    cursor: pointer;
    background-color: #f2f2f2;
  }

  .name {
    margin: 4px;
    font-weight: bold;
  }

  .desc {
    margin: 4px;
    color: #bfcce0;
  }
}
</style>